<?php

/**
 * Description of Article
 *
 * @author Vu
 */
 
class Article extends Zend_Db_Table_Abstract {
	
	protected $_name = 'cms_article';
    protected $_primary = 'article_id';
    
	public function getAllArticles($page = 1, $order = "created desc"){
        $tb = Zend_Db_Table::getDefaultAdapter();
        $tb->setFetchMode(Zend_Db::FETCH_OBJ);
        
        $select = $tb->select()->from('cms_article')->order($order);
        
        $paginator = Zend_Paginator::factory($select);
    	$paginator->setItemCountPerPage(Zend_Registry::get('page_size'));
    	$paginator->setCurrentPageNumber($page);        
           
        return $paginator;
    }
    
	public function getArticleById($articleid) {
        $row = $this->fetchRow($this->select()->where('article_id=?', $articleid));
        
        return $row;
    }
}